<template>
    <div class="box">
        <header class="header">

            <van-nav-bar title="收获地址" left-arrow @click-left="$router.back()" />
        </header>
        <div class="content">
            <van-address-list v-model="chosenAddressId" :list="addressList" @add="onAdd" @edit="onEdit"
                @select="onSelect" />
        </div>
    </div>
</template>

<script>
import { useCounterStore } from '@/store/index.js';
import { mapState, mapActions } from 'pinia'
export default {
    data() {
        return {
            chosenAddressId: '1',
        }
    },
    computed: {
        ...mapState(useCounterStore, ['addressList', 'checkedAddress'])
    },
    created() {
        this.chosenAddressId = this.checkedAddress.id
    },
    methods: {
        ...mapActions(useCounterStore, ['changeisChecked']),
        onSelect(item) {
            this.changeisChecked(item.id)
            this.$router.go(-1)
        }
    }
}

</script>